package com.devunion.salon.server.rpc;

import com.devunion.salon.client.app.bean.AddressBeanModel;
import com.devunion.salon.client.app.bean.CountryBeanModel;
import com.devunion.salon.client.app.bean.OfficeBeanModel;
import com.devunion.salon.client.app.bean.StateBeanModel;
import com.devunion.salon.client.rpc.CompanyService;
import com.extjs.gxt.ui.client.data.BaseListLoadResult;
import com.extjs.gxt.ui.client.data.ListLoadConfig;
import com.extjs.gxt.ui.client.data.ListLoadResult;
import org.gwtwidgets.server.spring.GWTSpringController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Timoshenko Alexander 01.03.2009 : 11:51:39
 */
public class CompanyServiceImpl extends GWTSpringController implements CompanyService {
    public ListLoadResult<OfficeBeanModel> getCompanyOffices(ListLoadConfig config) {
        List<OfficeBeanModel> result = new ArrayList<OfficeBeanModel>();

        for (int j = 0; j < 5; j++) {
            for (int i = 0; i < 5; i++) {
                OfficeBeanModel officeBeanModel = new OfficeBeanModel();
                officeBeanModel.setCode("Code"+i);

                AddressBeanModel addressBeanModel = new AddressBeanModel();
                addressBeanModel.setAddress1("address1");
                addressBeanModel.setAddress2("address2");
                addressBeanModel.setCity("city" + i);
                addressBeanModel.setCountry(new CountryBeanModel("code", "value"));
                addressBeanModel.setEmail("email@email.com");
                addressBeanModel.setFax("fax");
                addressBeanModel.setMobilePhone("mobilePhone");
                addressBeanModel.setPhone("phone");
                addressBeanModel.setZipCode("zip code");
                addressBeanModel.setState(new StateBeanModel("code", "value"));
                officeBeanModel.setAddress(addressBeanModel);

                result.add(officeBeanModel);
            }
        }
        return new BaseListLoadResult(result);
    }
}
